package cn.tedu.imop.basic.controller;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import cn.tedu.imop.common.constants.Constants;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.basic.entity.BusinessCategory;
import cn.tedu.imop.basic.service.BusinessCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags="商家分类")
@RestController
@RequestMapping(Constants.CONTROLLER_API_VERSION +"/business/category")
public class BusinessCategoryController {
    private final BusinessCategoryService bussinessCategoryService;
    public BusinessCategoryController(BusinessCategoryService bussinessCategoryService) {
        this.bussinessCategoryService = bussinessCategoryService;
    }
    @ApiOperation("添加分类")
    @PostMapping
    public RestResult<BusinessCategory> createBusinessCategory(BusinessCategory category) {
        bussinessCategoryService.createBusinessCategory(category);
        return RestResultUtils.success();
    }
    @ApiOperation("分类列表")
    @GetMapping
    public RestResult<PageData<BusinessCategory>> getBusinessCategoryList(BusinessCategory category) {
        return RestResultUtils.success(bussinessCategoryService.getBusinessCategoryList(category));
    }
}
